/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cxhd.dc.task;

import akka.actor.ActorRef;
import com.cxhd.dc.DataConfig;
import com.cxhd.dc.actor.ActorManager;
import com.cxhd.dc.tool.FileUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class ScanZipToQueueTask extends BaseTask {

    private BlockingQueue unzipQueue;
    private List<File> list = new ArrayList<File>();
     private ActorManager actorManager = ActorManager.getIntance();
    public ScanZipToQueueTask(BlockingQueue unzipQueue) {
        this.unzipQueue = unzipQueue;
    }

    @Override
    public BaseTask start() {
        list = FileUtil.getFile(DataConfig.getInstance().getBasePath() + "/" + DataConfig.getInstance().getDownloadFolder(), true, ".f");
        return this;
    }

    @Override
    public BaseTask doTask() {

        if (list!=null&&!list.isEmpty()) {
            for (File file : list) {
                try {
                    System.out.println(file.getName());
                   // unzipQueue.put(file);
                   actorManager.getActor("upzipActor").tell(file, ActorRef.noSender());
                } catch (Exception ex) {

                }
            }
        }
        return this;
    }

    @Override
    public BaseTask stop() {
        return this;
    }

    @Override
    public BaseTask cancelTask() {
        return this;
         }

}
